<template>
  <div class="container">
    <!-- <div class="height-100"></div>
    <div>queryStr: {{ queryStr }}</div> -->
  </div>
</template>

<script>
  export default {
    components: { },
    data() {
      return {
        hasData: false,
        hasNoneData: false,
        liveData: {},
        goodList: [],
        showTip: false,
        subscribe: '',
        room_id: '',
        queryStr: ''
      }
    },
    onLoad() {
      // 初始化data
      Object.assign(this.$data, this.$options.data())
    },
    mounted() {
      // 方式1：扫码小程序直播码（公众号平台里单个直播分享里的码），
      // this.getCurrentPage().query，返回 {'type':'1', 'room_id':'50'}
      // 方式2：点击服务通知的直播订阅提醒通知，
      // this.getCurrentPage().query，返回 {'subscribe':'1', 'room_id':'50'}
      // if (this.getCurrentPage().query) {
      //   this.queryStr = JSON.stringify(this.getCurrentPage().query)
      // }
      if (this.getCurrentPage().query.subscribe) {
        this.subscribe = this.getCurrentPage().query.subscribe
      }
      if (this.getCurrentPage().query.room_id) {
        this.room_id = this.getCurrentPage().query.room_id
        this.liveTo(this.room_id)
      } else {
        this.$pt.reLaunch({ url: '/pages/home/live-list/main' })
      }
    },
    methods: {
      liveTo(roomid) {
        let customParams = {
          liveShareMemberId: this.getMemberId,
          liveShareCustomerId: this.getCustomerId
        }
        this.$pt.redirectTo({
          url: 'plugin-private://' + process.env.LIVE_ID + '/pages/live-player-plugin?room_id=' + roomid +
           '&custom_params=' + encodeURIComponent(JSON.stringify(customParams))
        })
      }
    }
  }
</script>

<style lang="less" scoped>
.container{
  min-height: 100vh;
  background: #f8f8f8;
}
</style>
